package io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

/**
 * 说明:
 *
 * @author: luohaowei
 * @date:2023/3/8
 **/
public class isrdemo {
    public static void main(String[] args) throws IOException {
        FileInputStream fis=new FileInputStream("osw.txt");
        InputStreamReader isr=new InputStreamReader(fis, StandardCharsets.UTF_8);
        /*
        int read ()
        读取1个字符(到底读几个字节要根据他的内容以及对应的字符集来决定)
        返回的int值实际上是一个char,返回-1表示读取了末尾
         */
        int d;
        while((d=isr.read())!=-1){
            System.out.println((char)d);
        }
        isr.close();
        /*
        FileInputStream fis=new FileInputStream("osw.txt");
        InputStreamReader isr=new InputStreamReader(fis, StandardCharsets.UTF_8);
        int d;
        while((d=isr.read())!=-1){
            System.out.prineln((char)d);
        }
        isr.close();
         */
    }
}
